import React, { Component } from 'react'
import Header from '@/components/Header';
import Footer from '@/components/Footer';
import Context from '@/components/context';

import StepList from './StepList';
import Banner from './Banner';
import { actions as ACTIONS } from '@/components/Login'
import store from '@/store'



class Index extends Component {
  constructor(props) {
    super(props)
    this.getValue = this.getValue.bind(this);
    this.state = {
      searchInputVal: '',
      isLogin: props.isLogin,
      timeout:false
    }
    
    this.SearchName = '';

    // 登录注册
    this.doRegisterFn = this.doRegisterFn.bind(this);
    this.doLoginFn = this.doLoginFn.bind(this);

    document.title = '企业名片';
  }

  getValue(v) {
    // console.log(v,'**/')
    this.setState({
      
    })
  }

  closeModalFn() {
    this.setState({
      showModal: false,
      isClickTree: false
    })
  }


  doLoginFn(res, type) {
    if (type === 'register') {
      this.setState({
        showLogin: res,
        showRegister: true
      })
    } else if (type === 'changepas') {
      this.setState({
        showLogin: res,
        showChangepas: true
      })
    } else {
      this.setState({
        showLogin: res
      })
      if(!res){
        store.dispatch(ACTIONS.showLogin(false));
      }
    }
  }

  doRegisterFn(res, type) {
    if (type) {
      this.setState({
        showRegister: res,
        showLogin: true
      })
    } else {
      this.setState({
        showRegister: res
      })
    }
  }


  onTimeout(){
    this.setState({ timeout: false })
    store.dispatch(ACTIONS.isTimeout(false))
  }


  render() {
    // const { isLogin } = this.state;
    return (
      <div className="true_box">
        <Header doLogin={this.doLoginFn} doRegister={this.doRegisterFn} />

        <Context.Provider value={this.getValue}>
          <Banner />
        </Context.Provider>

        <StepList />
        <Footer />
      </div>
    )
  }
}

export default Index;